<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品列表</title>
    <style type="text/css">
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            color: #333;
        }
        a {
            text-decoration: none;
            color: #007BFF;
        }
        a:hover {
            text-decoration: underline;
        }
        table {
            width: 80%;
            margin: 20px auto;
            border-collapse: collapse;
            background-color: white;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        th, td {
            padding: 15px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f2f2f2;
            color: #333;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #f1f1f1;
        }
        .pagination {
            display: flex;
            justify-content: center;
            align-items: center;
            margin-top: 20px;
        }
        .pagination a {
            color: black;
            padding: 8px 16px;
            text-decoration: none;
            transition: background-color .3s;
            border: 1px solid #ddd;
            margin: 0 4px;
        }
        .pagination a.active {
            background-color: #007BFF;
            color: white;
            border: 1px solid #007BFF;
        }
        .pagination a:hover:not(.active) {background-color: #ddd;}

        a {
            display: inline-block;
            padding: 10px 20px;
            margin: 5px;
            font-size: 16px;
            color: #fff;
            text-align: center;
            text-decoration: none;
            background-color: #007BFF;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s, transform 0.3s;
        }

        a:hover {
            background-color: #0056b3;
            transform: scale(1.05); /* Slight zoom effect on hover */
        }

        a:active {
            background-color: #004080;
        }

        /* Optional: Add different styles for the pagination links */
        .pagination a {
            background-color: #ddd;
            color: #333;
        }

        .pagination a.active,
        .pagination a:hover {
            background-color: #007BFF;
            color: #fff;
        }

        .pagination a:active {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <a href="/product/input">新增</a>

    <!-- 查询的表单 -->
    <form action="/product/list" method="post">
        <input type="hidden" name="currentPage" id="currentPage" value="1"/>
    </form>

    <table width="800px" cellpadding="0" cellspacing="0" align="center" border="1px">
        <tr>
            <td>ID</td>
            <td>productName</td>
            <td>price</td>
            <td>stock</td>
            <td>url</td>
            <td>description</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${pageResult.data}" var="product">
            <tr>
                <td>${product.id}</td>
                <td>${product.productName}</td>
                <td>${product.price}</td>
                <td>${product.stock}</td>
                <td><img src="${product.url}" width="100" height="100"/> </td>
                <td>${product.description}</td>
                <td>
                    <a href="/product/details?id=${product.id}">详情</a>
                </td>
            </tr>
        </c:forEach>

        <tr align="center">
            <td colspan="9">
                <a href="javascript:goPage(1);">首页</a>
                <a href="javascript:goPage(${pageResult.prevPage});">上一页</a>
                <a href="javascript:goPage(${pageResult.nextPage});">下一页</a>
                <a href="javascript:goPage(${pageResult.totalPage});">尾页</a>
                当前:${pageResult.currentPage}/${pageResult.totalPage}
                总条数:${pageResult.totalCount}
            </td>
        </tr>
        <script>
            function goPage(currentPage){
                document.getElementById("currentPage").value=currentPage;
                document.forms[0].submit();
            }
        </script>
    </table>
</body>
</html>
